package com.pass.one;

import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;

/**
 * Pass One reads Nodes from the original data file, put the nodes in
 * appropriate groups and outputs the format <GroupID, Node>.
 * 
 * @author bh349
 */
public class PassOne extends Configured implements Tool {

	public int run(String[] args) throws Exception {
		Job job = new Job(getConf(), "pass 1");
		job.setJarByClass(PassOne.class);
		job.setMapperClass(PassOneMapper.class);
		job.setReducerClass(PassOneReducer.class);
		job.setOutputKeyClass(IntWritable.class);
		job.setOutputValueClass(Text.class);
		FileInputFormat.addInputPaths(job, "pass0");
		FileOutputFormat.setOutputPath(job, new Path("pass1out"));
		return job.waitForCompletion(true) ? 0 : 1;
	}
}
